package com.awei.study.design.action.common;

import java.util.Set;

/**
 * @Author liweilong
 * @Date 2024/8/14 22:31
 */
public class OrderCommon implements Common{

    private Chef chef;
    private Order order;

    public OrderCommon(Chef chef,Order order) {
        this.chef = chef;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getTableNum() + "号桌菜开始制作");
        Set<String> set = order.getOrders().keySet();
        for (String name : set) {
            chef.cook(order.getOrders().get(name),name);
        }

        //停顿一段时间模拟做菜
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(order.getTableNum() + "号桌菜做好了");
    }
}
